<?php
session_start(); 
require_once('../include/connect.inc.php');
require_once('../include/layout-jquery.php');
$r_teacher_id=$_SESSION['id'];
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
	alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
		location="login.php";
</script>
<?php }?>
<?php
$start_dates 	= $_POST['start_dates'];
$end_dates 	= $_POST['end_dates'];
$start_dates=date('Y-m-d H:i:s ', strtotime("$start_dates"));
$end_dates=date('Y-m-d H:i:s ', strtotime("$end_dates"));
	if($_GET[op] == "addset"){
		if($_POST['level_q'][5]==""){
			/*for($i=0;$i<=13;$i++){
			$bb=$_POST['set_num'];
			echo $aa=$aa+$bb[$i];
				if($aa=0){
					$empty=999;
				}
			}*/
			$_POST[set_num_match]=0;
			}
	$strSql="INSERT INTO tb_set_of_test (rangetest_id,subject_id,topic_id,point,set_date_cre,start_dates,end_dates,set_sum_question,set_num_match,set_time_dotest,r_teacher_id) VALUES ('".$_POST[rangetest_id]."','".$_POST[subject]."','".$_POST[topic]."','".$_POST[point]."','".$_POST[set_date_cre]."','{$start_dates}','{$end_dates}','".$_POST[set_sum_question]."','".$_POST[set_num_match]."','".$_POST[set_time_dotest]."','".$_SESSION['id']."')";
		execute($strSql);
		$query1 = query("select * from tb_set_of_test  order by set_id desc");
			$rs = fetch_array($query1);
			$set_id = $rs['set_id'];
			$rangetest_id = (int)$rs['rangetest_id'];
//เงื่อนไขเพิ่มในตาราง tb_gen_to_dotest
	$set_num=$_POST[set_num];
	$level_q=$_POST[level_q];
	$type_id=$_POST[type_id];
	for($i=0;$i<=13;$i++){
		if($_POST['set_num'][$i]!=0){
			$_POST['set_num'][$i];
			$_POST['level_q'][$i];
			$_POST['type_id'][$i];
	$strSql = "INSERT INTO tb_gen_torand (type_id, level_q_id, num,num_match, set_id, topic_id, rangetest_id) VALUES (".$type_id[$i].",'".$level_q[$i]."','".$set_num[$i]."','0','".$set_id."','".$_POST['topic']."','".$_POST['rangetest_id']."')";
	$rs = execute( $strSql );
		}
	}
if($_POST['level_q'][5]!=""){
	$set_num_match=$_POST['set_num_match'];
	$level_q=$_POST['level_q'][5];
	$type_id=$_POST['type_id'][5];
	$strSql = "INSERT INTO tb_gen_torand (type_id, level_q_id, num,num_match, set_id, topic_id, rangetest_id) VALUES (".$type_id.",'".$level_q."',0,'$set_num_match','".$set_id."','".$_POST['topic']."','".$_POST['rangetest_id']."')";
	$rs = execute( $strSql );	
	}
	if(!$rs){
			$msg = "เกิดข้อผิดพลาดโปรดทำรายการใหม่";
				header("location:frm_cre_set.php");
		}else{
		?>
<SCRIPT LANGUAGE="JavaScript">
	alert("เพิ่มชุดข้อสอบเรียบร้อยแล้ว...!");
	location="frm_show_set.php";
</script>
<?php 
		}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="../template/template_style_wood.css">

<script type="text/javascript" src="../js/exam/show_question.js"></script>
<script language = "JavaScript">
function IsNumeric(n){
	var pattern = /^[0-9]/;
	if ( !pattern.test(n.value) && n.value != '' ) {
		alert("กรุณาใส่ตัวเลข");
		n.value='';
	}
}

</script>
<script type="text/javascript" src="../javaSC/ckeditor.js"></script>
<script type="text/javascript" src="../javaSC/datepicker.js"></script>
<script language="javascript" type="text/javascript" src="../javaSC/datetimepicker.js">
//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com 
</script>
</head>
<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a  href="../person_tea.php">ข้อมูลส่วนตัว</a>
		<a href="../tea_edit.php">เปลี่ยนรหัสผ่านใหม่</a>
        
        <a href="show_subject.php">จัดการรายวิชา</a>
		<a  href="../teacher_test.php">จัดการข้อสอบ</a>
        <a class="active" href="../teacher_tests.php">จัดการชุดข้อสอบ</a>
        <a  href="../agree_set.php">กำหนดสิทธิ์</a>
		<a href="../exam/tea_chack.php">ตรวจสอบคะแนน</a>
        <a href="../news/manage_news.php">ประกาศข่าวสาร</a>
        <a href="../problem/send_problem.php">แสดงความคิดเห็น</a>
        <a href="../logout.php">ออกจากระบบ</a>
		</div></div>           
 <div id="p3">    
<div id="header"></div>
   <div id="page"><div id="p1">คุณ<?php echo $_SESSION['teacher_name'];?><hr/>
   <script language="javascript">
		function fncSubmit()
		{
		if(document.form3.subject.value=="0"){
				alert('กรุณาเลือกวิชา');
				document.form3.subject.focus();
				return false;
			}
			if(document.form3.topic.value=="0"){
				alert('กรุณาเลือกหัวข้อ');
				document.form3.topic.focus();
				return false;
			}
			if(document.form3.rangetest_id.value == "0"){
				alert('กรุณาเลือกช่วงการสอบ');
				document.form3.rangetest_id.focus();       
				return false;
			}
			if(document.form3.point.value == ""){
				alert('กรุณากรอกกำหนดคะแนน');
				document.form3.point.focus();       
				return false;
			}  
			if(document.form3.set_time_dotest.value == ""){
				alert('กรุณากรอกเวลาทำข้อสอบ');
				document.form3.set_time_dotest.focus();       
				return false;
			}
		   if(document.form3.start_dates.value == ""){
				alert('กรุณาเลือกเริ่มใช้ข้อสอบ');
				document.form3.start_dates.focus();       
				return false;
			}  
			 if(document.form3.end_dates.value == ""){
				alert('กรุณาเลือกข้อสอบหมดอายุการใช้งาน');
				document.form3.end_dates.focus();       
				return false;
			} 
			document.form3.submit();
	}
</script>
<table class="p21" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left"><font size="+1">สร้างชุดข้อสอบ</font></th>
        <th align="left"><a href="../teacher_tests.php"><img src="../images/undo.png" border="0" /></a></th>
      </tr>
</table>
<form id="form3" name="form3" method="post" onSubmit="JavaScript:return fncSubmit();">
<?php echo $msg; ?>
<table border="0" class="p23" >
    <tr>
      <td width="140" align="right">วิชา :</td>
      <td width="266" colspan="3"><select id="subject" name="subject" onchange = "listTopic(this.value)">
          <option selected value="0">=====เลือก====</option>
	<?php
		$strSQL ="SELECT * FROM tb_agree_teacher
	Inner Join tb_subject ON  tb_subject.subject_id = tb_agree_teacher.subject_id where tb_agree_teacher.r_teacher_id='$r_teacher_id' ORDER BY 			tb_subject.subject_id ASC";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
          <option value="<?=$objResult["subject_id"];?>">
          <?=$objResult["subject_name"];?>
          </option>
          <?
		 }
		?>
        </select></td>
      </tr>
    <tr>
      <td align="right">หัวข้อหลัก : </td>
      <td colspan="3"><select id="topic" name="topic" style="width:130px">
          <option selected="selected" value="0">==============</option>
        </select></td>
    </tr>
    <tr>
      <td align="right">ช่วงการสอบ :</td>
      <td colspan="3"><select name="rangetest_id" id="rangetest_id">
        <option selected value="0">====เลือก===</option>
          <?  
		$query2 = query("SELECT * FROM tb_rangetest");
		while ($rs2 = fetch_array($query2)) {
	  ?>
          <option value="<? echo $rs2[rangetest_id]; ?>"><? echo $rs2[rangetest_detail];?></option>
          <? }?>
          </select></td>
      </tr>
<?php /*?><tr>
      <td colspan="3">จำนวนข้อสอบ :
        <input name="set_sum_question" type="text" id="set_sum_question" size="8" onKeyUp="IsNumeric(this)"/> ข้อ</td>
      </tr>
      <tr>
      <td colspan="3">จำนวนข้อสอบจับคู่ :
        <input name="sum_match_set" type="text" id="sum_match_set" size="8" onKeyUp="IsNumeric(this)"/> ชุด</td>
      </tr><?php */?>
       <tr>
         <td align="right">กำหนดคะแนน :</td>
      <td colspan="3"><input name="point" type="text" id="point" size="2" onKeyUp="IsNumeric(this)" value="1"/> 
        คะแนน : ข้อ</td>
      </tr>
    <tr>
      <td align="right">เวลาทำข้อสอบ :</td>
      <td colspan="3"><input name="set_time_dotest" type="text" id="set_time_dotest" onKeyUp="IsNumeric(this)" size="2" />
        นาที</td>
    </tr>
    <tr>
      <td align="right">เริ่มใช้ข้อสอบ : </td>
      <td colspan="3"><input name="start_dates" id="start_dates" value="<?=$_GET[start_dates];?>" readonly="readonly" />
        <a href="javascript:NewCal('start_dates','ddmmyyyy',true,24)"><img src="../images/dateselect.gif" width="16" height="16" border="0" alt="Pick a date"></a></td>
      </tr>
    <tr>
      <td align="right">ข้อสอบหมดอายุการใช้งาน :</td>
      <td colspan="3"><input name="end_dates" id="end_dates"readonly="readonly" value="<?=$_GET[end_dates];?>" />
        <a href="javascript:NewCal('end_dates','ddmmyyyy',true,24)"><img src="../images/dateselect.gif" width="16" height="16" border="0" alt="Pick a date"></a>        </td>
    </tr>
    <tr>
      <td align="right">&nbsp;</td>
      <td colspan="3"><input type="submit" name="btn_next" id="btn_next" value="ดำเนินการต่อ" />
        <input type="reset" name="btn_reset" id="button" value="ยกเลิก" /></td>
    </tr>
</table>
</form>

<?php 
if($_POST['btn_next'] == 'ดำเนินการต่อ'){ 
?>
<form id="addset" name="frmMain" method="post" action="frm_cre_set.php?op=addset">
	<input type="hidden" name="subject" id="subject" value="<?php echo $_POST[subject];?>">
	<input type="hidden" name="topic" id="topic" value="<?php echo $_POST[topic];?>">
	<input type="hidden" name="rangetest_id" id="rangetest_id" value="<?php echo $_POST[rangetest_id];?>">
	<input type="hidden" name="point" id="point" value="<?php echo $_POST[point];?>">
	<input type="hidden" name="set_time_dotest" id="set_time_dotest" value="<?php echo $_POST[set_time_dotest];?>">
	<input type="hidden" name="start_dates" id="start_dates" value="<?php echo $_POST[start_dates];?>">
	<input type="hidden" name="end_dates" id="end_dates" value="<?php echo $_POST[end_dates];?>">
<table border="0" class="p23" >
    <tr>
      <td colspan="4"><li>ประเภทข้อสอบ</li></td>
    </tr>
    <tr>
      <td width="152">
      1.เลือกตอบได้ตัวเลือกเดียว </td>
      <td width="170">จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1'");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[1]" id="set_num1">
<option value="0">0</option>
<?php
$q1=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1'");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q1++;
?>
<option value="<?php echo "$q1";?>"><?php echo "$q1";?></option>
<? }?>
</select>
<?php }?>

ข้อ(ง่าย)
<input name="level_q[1]" type="hidden" id="level_q_id1" value="1" />
<input name="type_id[1]" type="hidden" id="type_id1" value="1" /></td>
      <td width="190">จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2'");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[6]" id="set_num6">
	<option value="0">0</option>
<?php
$q5=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q5++;
?>
          <option value="<?php echo "$q5";?>"><?=$q5?></option>
<?php }?>
</select>
<?php }?>

ข้อ(ปานกลาง)
<input name="level_q[6]" type="hidden" id="level_q_id6" value="2" />
<input name="type_id[6]" type="hidden" id="type_id6" value="1" /></td>
      <td width="164">จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
        <select name="set_num[10]" id="set_num9">
          <option value="0">0</option>
<?php
$q9=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='1' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q9++;
?>
<option value="<?php echo "$q9";?>"><?php echo "$q9";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ยาก)
<input name="level_q[10]" type="hidden" id="level_q_id10" value="3" />
<input name="type_id[10]" type="hidden" id="type_id10" value="1" /></td>
    </tr>
    <tr>
      <td>
2.เลือกตอบได้หลายตัวเลือก
  <label></label></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1'");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
        <select name="set_num[2]" id="set_num2">
        	<option value="0">0</option>
<?php
$q2=0;
	$query= query("SELECT * FROM tb_question where type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1'");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q2++;
?>
<option value="<?php echo "$q2";?>"><?php echo "$q2";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ง่าย)
<input name="level_q[2]" type="hidden" id="level_q_id2" value="1" />
<input name="type_id[2]" type="hidden" id="type_id2" value="2" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[7]" id="set_num6">
<option value="0">0</option>
<?php
$q6=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q6++;
?>
<option value="<?php echo "$q6";?>"><?php echo "$q6";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ปานกลาง)
<input name="level_q[7]" type="hidden" id="level_q_id7" value="2" />
<input name="type_id[7]" type="hidden" id="type_id7" value="2" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[11]" id="set_num10">
<option value="0">0</option>
<?php
$q10=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='2' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q10++;
?>
<option value="<?php echo "$q10";?>"><?php echo "$q10";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ยาก)
<input name="level_q[11]" type="hidden" id="level_q_id11" value="3" />
<input name="type_id[11]" type="hidden" id="type_id11" value="2" /></td>
    </tr>
    <tr>
      <td> 
        3.ข้อสอบถูก-ผิด
      <label></label></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
        <select name="set_num[3]" id="set_num3">
        	<option value="0">0</option>
<?
$q3=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q3++;
?>
<option value="<?php echo "$q3";?>"><?php echo "$q3";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ง่าย)
<input name="level_q[3]" type="hidden" id="level_q_id3" value="1" />
<input name="type_id[3]" type="hidden" id="type_id3" value="3" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
        <select name="set_num[8]" id="set_num7">
          <option value="0">0</option>
<?php
$q7=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q7++;
?>
          <option value="<?php echo "$q7";?>"><?php echo "$q7";?></option>
<?php }?>
</select>
<?php } ?>

ข้อ(ปานกลาง)
<input name="level_q[8]" type="hidden" id="level_q_id8" value="2" />
<input name="type_id[8]" type="hidden" id="type_id8" value="3" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[12]" id="set_num11">
<option value="0">0</option>
<?php
$q11=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='3' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q11++;
?>
<option value="<?php echo "$q11";?>"><?php echo "$q11";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ยาก)
<input name="level_q[12]" type="hidden" id="level_q_id12" value="3" />
<input name="type_id[12]" type="hidden" id="type_id12" value="3" /></td>
    </tr>
    <tr>
      <?php /*?><td>
4.ข้อสอบเติมคำ	</td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
        <select name="set_num[4]" id="set_num4">
        	<option value="0">0</option>
<?
$q4=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q4++;
?>
<option value="<?php echo "$q4";?>"><?php echo "$q4";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ง่าย)
<input name="level_q[4]" type="hidden" id="level_q_id4" value="1" />
<input name="type_id[4]" type="hidden" id="type_id4" value="4" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[9]" id="set_num9">
<option value="0">0</option>
<?php
$q8=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q8++;
?>
<option value="<?php echo "$q8";?>"><?php echo "$q8";?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ปานกลาง)
<input name="level_q[9]" type="hidden" id="level_q_id9" value="2" />
<input name="type_id[9]" type="hidden" id="type_id9" value="4" /></td>
      <td>จำนวน
<?php
$query0= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
	if(num_rows($query0)<1){
		echo "-";
		}else{
?>
<select name="set_num[13]" id="set_num13">
<option value="0">0</option>
<?php
$q12=0;
	$query= query("SELECT * FROM tb_question where tb_question.type_id='4' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
		while ($rs= fetch_array($query)) {
			$question_id=$rs['question_id'];
			$q12++;
?>
<option value="<?=$q1?>"><?=$q1?></option>
<? }?>
</select>
<?php } ?>

ข้อ(ยาก)
<input name="level_q[13]" type="hidden" id="level_q_id13" value="3" />
<input name="type_id[13]" type="hidden" id="type_id13" value="4" /></td><?php */?>
    </tr>
    <tr>
      <td>
4.ข้อสอบจับคู่</td>
      <td colspan="3">จำนวน
<input type="hidden" name="set_num_match" id="set_num_match" value="1">&nbsp;&nbsp;1</input>
<input name="type_id[5]" type="hidden" id="type_id5" value="5" />
&nbsp;&nbsp;&nbsp;&nbsp;ชุดระดับ:
<?php 
$query= query("SELECT * FROM tb_question where tb_question.type_id='5' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='1' ");
	if(num_rows($query)<1){
		echo "";
	}else{
	echo "<input type=\"radio\" name=\"level_q[5]\" id=\"level_q[5]\" value=\"1\" />:ง่าย";
	}
?>
<?php 
$query= query("SELECT * FROM tb_question where tb_question.type_id='5' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='2' ");
	if(num_rows($query)<1){
		echo "";
	}else{
	echo "<input type=\"radio\" name=\"level_q[5]\" id=\"level_q[5]\" value=\"2\" />:ปานกลาง";
	}
?>
<?php 
$query= query("SELECT * FROM tb_question where tb_question.type_id='5' AND tb_question.topic_id='$topic' AND tb_question.level_q_id='3' ");
	if(num_rows($query)<1){
		echo "";
	}else{
	echo "<input type=\"radio\" name=\"level_q[5]\" id=\"level_q[5]\" value=\"3\" />:ยาก";
	}
?>
<input name="level_q[5]" type="radio" id="level_q[5]" checked="checked" value="" />ไม่เลือกข้อสอบจับคู่
</td>
      </tr>
    <tr>
      <td colspan="4">วันที่สร้าง :  <?php echo $date=date("Y-m-d");?>
      <input type="hidden" name="set_date_cre" id="set_date_cre" value="<?php echo $date=date("Y-m-d");?>"/></td>
    </tr>
  </table>
  <input type="submit" name="btn_save" id="btn_save" value="บันทึกข้อมูล" />
</form>
<?php }?>
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>
